/*
ID       Date (UTC)              Status    CPU      Memory    Author Source   Problem / Title
553466 2010-03-06 01:43:08 Accepted 0.014 Minimum 9056    C++   4733 - Seinfeld
*/
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int seinfeld(const string& s) {
   int operaciones = 0;
   stack<char> pila;
   const int SIZE = s.size();
   for (int i = 0; i < SIZE; ++i) {
      if (s[i] == '{') {
         pila.push(s[i]);
      } else {
         if (pila.empty()) {
            ++operaciones;
            pila.push('{');
         } else {
            pila.pop();
         }
      }
   }
   if (!pila.empty()) {
      operaciones += pila.size() / 2;               
   }
   return operaciones;
}

int main() {
   string s;
   cin >> s;
   int caso = 1;
   while(s[0] != '-') {
      cout << caso++ << ". " << seinfeld(s) << endl;
      cin >> s;
   }
   return 0;
}
